<div class="main">
  <div class="main-header">
    <div class="pa-icon-div pull-left fs-14">
      <i class="iconfont icon-shouye fs-14 icon-vertical-top"></i>
      <span class="fs-vertical-middle">系统设置>
        <span class="fs-theme-color">设备资料</span>
      </span>
    </div>
  </div>
  <div class="main-content">
    <div class="search-info">
      <div class="container-header fs-16">
        <span>设备资料列表</span>
      </div>
      <form class="base-info">
        <div class="base-info-item">
          <div class="pa-form-control">
            <label>资料名称：</label>
            <input type="text" class="pa-form-control-input"
              ng-model="vm.mapParams.documentName">
          </div>
          <div class="pa-form-control">
            <label>资料编码：</label>
            <input type="text" class="pa-form-control-input"
              ng-model="vm.mapParams.documentNumber">
          </div>
          <div class="pa-form-control pa-form-control-btn text-right w-100">
            <button class="pa-btn pa-sw-btn" type="button"
              ng-click="vm.$paginationQuery()">搜索</button>
            <button class="pa-btn pa-sw-btn reset-btn" type="reset"
              ng-click="vm.$reset()">重置</button>
          </div>
        </div>
        <div class="pa-operate-fr fs-theme-color"
          ng-click="vm.$addDocument(vm)">
          <i class="iconfont icon-middle icon-22 fs-14"></i>
          <span>上传资料</span>
        </div>
      </form>
    </div>
    <pa-table>
      <table class="pa-table">
        <thead>
          <tr>
            <th class="sorting"
              ng-class="{'sorting-desc': vm.mapParams.sortType == 2, 'sorting-asc': vm.mapParams.sortType == 1}"
              ng-click="vm.$toggleOrder('document_number')">
              资料编号
            </th>
            <th>资料名称</th>
            <th>编制时间</th>
            <th class="operate-three">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="item in vm.deviceDocumentData track by $index">
            <td>{{item.documentNumber}}</td>
            <td>{{item.documentName}}</td>
            <td>{{item.compileTime | date:'yyyy-MM-dd'}}</td>
            <td>
              <div class="operate-del" ng-click="vm.$editDocument(item, vm)">
                <i class="iconfont icon-xiugai1 edit-color fs-12"></i>
                <span>修改</span>
              </div>
              <div class="operate-del" ng-click="vm.$delete(item.id, vm)">
                <i class="iconfont icon-middle icon-shanchu trash-color fs-12"></i>
                <span>删除</span>
              </div>
            </td>
            <!-- <td expand-name="附件名" expand-value="item.files">
              <div class="text-left" ng-repeat="file in item.files">
                <span>{{file.fileName}}</span>
                <button class="pa-sm-btn" ng-click="vm.method.downLoad(value)">下载</button>
                <button class="pa-sm-btn reset-btn" ng-click="vm.method.preview(value)">预览</button>
              </div>
            </td> -->
          </tr>
        </tbody>
      </table>
    </pa-table>
  </div>
</div>

<!-- 新增弹窗 -->
<script type="text/ng-template" id="paAddItemDialog">
  <div class="pa-dialog">
    <div class="pa-dialog-header">
      <div class="title-txt">
        <span>上传资料</span>
      </div>
    </div>
    <div class="pa-dialog-content text-center document-dialog-file">
      <form name="addForm">
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>资料编号：</label>
          <input type="text" class="form-control-input" ng-model="vm.reqData.documentNumber">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>资料名称：</label>
          <input type="text" class="form-control-input" ng-model="vm.reqData.documentName">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right"><b>*</b>编制时间：</label>
          <input type="text" class="pa-form-control-input date-picker"
            data-ng-datepicker
            ng-model="vm.reqData.compileTime">
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right">备注：</label>
          <textarea type="text" class="form-control-textarea"
            ng-model="vm.reqData.remark"></textarea>
        </div>
        <div class="pa-form-control pa-width-100">
          <label class="text-right">附件：</label>
          <div class="pa-operate-add fs-14 fs-theme-color dialog-file-btn">
            <a class="pa-btn-a"
              attachment-uploader
              data-url="/api/v1/common/uploadFile?folderName=device"
              data-target=".file-list"
              ng-model="vm.view.attachmentFiles">
              <span>上传附件</span>
            </a>
          </div>
        </div>
        <div class="file-list" style="min-height: 30px;">
          <div class="upload-result">
            <div class="result-item" ng-repeat="file in vm.view.attachmentFiles">
              <span class="file-name">{{file.name}}</span>
              <span>{{file.humanSize}}</span>
              <i class="fa fa-times-circle file-remove-btn" ng-click="$removeFile(file);"></i>
              <span ng-if="file.success === false">上传失败</span>
              <progress ng-if="file.isUploading" class="progress-bar" value="{{file.loaded}}" max="{{file.size}}"></progress>
            </div>
          </div>
        </div>
      </form>
    </div>
    <div class="pa-dialog-footer text-center">
      <a class="pa-btn" ng-click="vm.submitForm(addForm)">
        <span>确定</span>
      </a>
      <a class="pa-btn reset-btn" ng-click="closeThisDialog()">
        <span>取消</span>
      </a>
    </div>
  </div>
</script>

<!-- 查看弹窗 -->
<script type="text/ng-template" id="paViewItemDialog">
  <div class="pa-dialog">
    <div class="pa-dialog-header">
      <div class="title-txt">
        <span>查看资料</span>
      </div>
    </div>
    <div class="pa-dialog-content text-center document-dialog-file">
      <div class="pa-form-control pa-width-100">
        <label class="text-right">资料编号：</label>
        <span class="view-span">{{vm.document.documentNumber}}</span>
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right">资料名称：</label>
        <span class="view-span">{{vm.document.documentName}}</span>
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right">编制时间：</label>
        <span class="view-span">{{vm.document.compileTime | date: 'yyyy-MM-dd'}}</span>
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right">备注：</label>
        <span class="view-span">{{vm.document.remark}}</span>
      </div>
      <div class="pa-form-control pa-width-100">
        <div class="fs-14">
          <div class="file-list">
            <div class="file-item" ng-repeat="file in vm.document.files">
              <span class="file-item-span fl">{{file.fileName}}</span>
              <!-- <button class="pa-btn" type="button">预览</button>
              <button class="pa-btn" type="button">下载</button> -->
              <a class="pa-btn file-del-btn" target="_blank"
                ng-href="{{vm.getDownloadSrc(file.id)}}" download="{{file.fileName}}">下载</a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</script>

<!-- 编辑弹窗 -->
<script type="text/ng-template" id="paEditItemDialog">
  <div class="pa-dialog">
    <div class="pa-dialog-header">
      <div class="title-txt">
        <span>修改资料</span>
      </div>
    </div>
    <div class="pa-dialog-content text-center document-dialog-file">
      <div class="pa-form-control pa-width-100">
        <label class="text-right"><b>*</b>资料编号：</label>
        <input type="text" class="form-control-input"
          ng-model="vm.document.documentNumber">
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right"><b>*</b>资料名称：</label>
        <input type="text" class="form-control-input"
          ng-model="vm.document.documentName">
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right"><b>*</b>编制时间：</label>
        <input type="text" class="pa-form-control-input date-picker"
          data-ng-datepicker
          ng-model="vm.document.compileTime">
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right">备注：</label>
        <textarea type="text" class="form-control-textarea"
          ng-model="vm.document.remark"></textarea>
      </div>
      <div class="pa-form-control pa-width-100">
        <label class="text-right">附件：</label>
        <div class="pa-operate-add fs-14 fs-theme-color dialog-file-btn">
          <a class="pa-btn-a"
            attachment-uploader
            data-url="/api/v1/common/uploadFile?folderName=device"
            data-target=".file-list"
            ng-model="vm.view.attachmentFiles">
            <span>上传附件</span>
          </a>
        </div>
        <div class="file-list" style="min-height: 30px;">
          <div class="upload-result">
            <div class="result-item" ng-repeat="file in vm.view.attachmentFiles">
              <span class="file-name">{{file.name}}</span>
              <span>{{file.humanSize}}</span>
              <i class="fa fa-times-circle file-remove-btn" ng-click="$removeFile(file);"></i>
              <span ng-if="file.success === false">上传失败</span>
              <progress ng-if="file.isUploading" class="progress-bar" value="{{file.loaded}}" max="{{file.size}}"></progress>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="pa-dialog-footer text-center">
      <a class="pa-btn" ng-click="vm.submitEditForm()">
        <span>确定</span>
      </a>
      <a class="pa-btn reset-btn" ng-click="closeThisDialog()">
        <span>取消</span>
      </a>
    </div>
  </div>
</script>